package com.weiyi.mashangzhu.Landlord.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.google.gson.Gson;
import com.squareup.okhttp.Request;
import com.weiyi.mashangzhu.API.API;
import com.weiyi.mashangzhu.Base.BaseActivity;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Activity.AwardActivity;
import com.weiyi.mashangzhu.Roomer.Activity.FriendActivity;
import com.weiyi.mashangzhu.Roomer.Activity.WithdrawActivity;
import com.weiyi.mashangzhu.Roomer.Bean.PersonInfoBean;
import com.weiyi.mashangzhu.Utils.GlideImgManager;
import com.weiyi.mashangzhu.Utils.LoadingDialog;
import com.weiyi.mashangzhu.Utils.SPUtils;
import com.weiyi.mashangzhu.Utils.T;
import com.weiyi.mashangzhu.Utils.UiUtil;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.json.JSONException;
import org.json.JSONObject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WalletCenterActivity extends BaseActivity {

    @BindView(R.id.count)
    TextView count;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wallet_center);
        ButterKnife.bind(this);
        LoadingDialog.show(this);
        OkHttpUtils.get()
                .addParams("token", SPUtils.get(this, "token", "") + "")
                .url(API.BaseApi_R + API.GetACCount_Api)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Request request, Exception e) {
                        LoadingDialog.dismiss(WalletCenterActivity.this);
                        T.showShort(WalletCenterActivity.this, "网络连接失败，请检查一下网络设置");
                    }

                    @Override
                    public void onResponse(String response) {
                        LoadingDialog.dismiss(WalletCenterActivity.this);
                        try {
                            JSONObject jsonObject=new JSONObject(response);
                            count.setText("¥ "+jsonObject.getString("data"));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                });
    }

    @OnClick({R.id.back, R.id.tx, R.id.layout_award, R.id.layout_friend})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.tx:
                //提现
                UiUtil.startActivity(this,WithdrawActivity.class);
                break;
            case R.id.layout_award:
                //平台奖励
                UiUtil.startActivity(this, AwardActivity.class);
                break;
            case R.id.layout_friend:
                //受邀好友
                UiUtil.startActivity(this, FriendActivity.class);
                break;
        }
    }
}
